package com.kingyun.gpsinspection.purificationservice.common.activiti;

import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.history.HistoricProcessInstanceQuery;
import org.activiti.engine.repository.ProcessDefinitionQuery;

/**
 * 中间操作类
 */
public class ActivitiMeditorFactory {

    private static ActivitiMeditorFactory mditorFactory=new ActivitiMeditorFactory();

    private ActivitiMeditorFactory(){

    }


    public static ActivitiMeditorFactory getInstance(){
        if(mditorFactory==null){
            mditorFactory=new ActivitiMeditorFactory();
        }
        return mditorFactory;
    }



    /**
     * 得到流程定义查询对象
     *
     * @return
     */
    public static ProcessDefinitionQuery createProcessDefinitionQuery(){
        RepositoryService repositoryService=(RepositoryService) ApplicationContextUtils.getBean("repositoryService");
        ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
        return processDefinitionQuery;
    }


    /**
     * 得到流程实例的查询对象
     *
     * @return
     */
    public static HistoricProcessInstanceQuery createProcessInstanceQuery(){
        HistoryService historyService=(HistoryService) ApplicationContextUtils.getBean("historyService");
        HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery();
        return historicProcessInstanceQuery;
    }


}
